package Demo6;

import java.io.FileOutputStream;
import java.io.OutputStream;

//字节流
public class FileOutputStreamTest1 {
    public static void main(String[] args) {
        OutputStream os = null;
        try {
            //创建输入流(拉通管道)
            os = new FileOutputStream("f:/TEST/hello.txt");
            //读取(流水)
            int len;
            String s = "好好学习";
            byte[] b = s.getBytes();
            //把读取到的结果打印出来
            os.write(b,0,b.length);
            os.write(s.getBytes());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                os.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
